package com.artpri.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.artpri.model.AdPicture;
import com.artpri.model.vo.RecGoods;
import com.artpri.model.vo.SimpleGoods;
import com.artpri.service.AdPictureService.ImageState;

/**
 * 商品相关页面广告
 * @author ZhangSi
 */
@Namespace("/page/goods")
@ParentPackage("json-default")
public class GoodsPageAction extends BaseAction {

	private static final long serialVersionUID = -7941417362998615555L;
	
	private Map<String, RecGoods> recWorkMap;
	
	private Map<String, AdPicture> bottomAdMap;
	
	private List<SimpleGoods> detailOneList;
	
	private List<SimpleGoods> detailTwoList;
	
	/**
	 * 筛选器左侧-推荐作品
	 * @return
	 * @throws Exception
	 */
	@Action(value="recWork", results={
			@Result(name="success", type="json", params={"root", "recWorkMap"})
	})
	public String recWork() throws Exception {
		recWorkMap = getAdPictureService().getRecWorkMapByPlate("00302", ImageState.SHOW);
		return SUCCESS;
	}

	/**
	 * 商品详情-左侧商品推荐
	 * @return
	 * @throws Exception
	 */
	@Action(value="detailLeft", results={
			@Result(name="success", type="json", params={"includeProperties", "detailOneList.*, detailTwoList.*"})
	})
	public String detailLeftOne() throws Exception {
		detailOneList = getAdPictureService().getGoodsDetailRecWorkList("00304", 6);
		detailTwoList = getAdPictureService().getGoodsDetailRecWorkList("00305", 6);
		return SUCCESS;
	}
	
	/**
	 * 商品详情-底部四个广告位
	 * @return
	 * @throws Exception
	 */
	@Action(value="detailBottomAd", results={
			@Result(name="success", type="json", params={"includeProperties", "bottomAdMap.*"})
	})
	public String detailBottomAd() throws Exception {
		bottomAdMap = getAdPictureService().getAdPictureMapByPlate("00306", ImageState.SHOW);
		return SUCCESS;
	}
	
	
	public List<SimpleGoods> getDetailOneList() {
		return detailOneList;
	}
	public void setDetailOneList(List<SimpleGoods> detailOneList) {
		this.detailOneList = detailOneList;
	}
	public List<SimpleGoods> getDetailTwoList() {
		return detailTwoList;
	}
	public void setDetailTwoList(List<SimpleGoods> detailTwoList) {
		this.detailTwoList = detailTwoList;
	}
	public Map<String, RecGoods> getRecWorkMap() {
		return recWorkMap;
	}
	public void setRecWorkMap(Map<String, RecGoods> recWorkMap) {
		this.recWorkMap = recWorkMap;
	}
	public Map<String, AdPicture> getBottomAdMap() {
		return bottomAdMap;
	}
	public void setBottomAdMap(Map<String, AdPicture> bottomAdMap) {
		this.bottomAdMap = bottomAdMap;
	}
}
